package com.qingke.notlonely.command.system;

import java.util.ArrayList;
import java.util.List;

import com.qingke.notlonely.bean.User;
import com.qingke.notlonely.bean.UserInterest;
import com.qingke.notlonely.command.SystemCommand;
import com.qingke.notlonely.util.NLConsole;

public class ListUserAndInterestByDegree extends SystemCommand{

	@Override
	public void execute() {
		int degree;
		while(true){
			degree=NLConsole.getInt("degree:");
			if(degree==0||degree>10){
				NLConsole.println("err input");
				continue;
			}
			break;
		}
		List<UserInterest> listUI=dao.selectUserInterestByGreateThanDegree(degree);
		List<User> listU=new ArrayList<>();
		for(UserInterest ui:listUI){
			User user=ui.getUser();
			if(!listU.contains(user))
				listU.add(user);
		}
		for(User user:listU){
			NLConsole.println(user);
			for(UserInterest ui:listUI){
				if(user.getId()==ui.getUser().getId()){
					NLConsole.println(ui.getInterest()+",degree:"+ui.getDegree());
				}
			}
		}
	}
}
